/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hanze.web.ola;

import java.util.HashMap;

/**
 *
 * @author Luuk
 */
public class AcceptGiroTransformer {
    
    private HashMap<String, String> data;
    public long reference;
    public int euro;
    public int cent;
    public String betalingskenmerk;
    public String adresPC;
    public String naam;
    
    public AcceptGiroTransformer(HashMap<String, String> data){
        this.data = data;
        reference = Long.parseLong(data.get("reference"));
        euro = Integer.parseInt(data.get("euro"));
        cent = Integer.parseInt(data.get("cent"));
        betalingskenmerk = transBetalingskenmerk(data.get("betalingskenmerk"));
        adresPC = transPlaatsPostcode();
        naam = transName();
    }
    
    public static String transBetalingskenmerk(String kenmerk){
        return kenmerk.replaceAll(".{4}", "$0 ");
    }
    
    public String transName(){
        String fullName;
        if(data.get("geslacht").equals("M")){
            fullName = "Dhr. ";
        }else {
            fullName = "Mevr. ";
        }
        return fullName += data.get("init") + " " + data.get("achternaam");
    }
    
    public String transPlaatsPostcode(){
        return data.get("plaatsnaam") + " " + data.get("straatnummer") + ", " + data.get("postcode").replaceAll(".{4}", "$0 ");
    }
    
}
